make: immediately expand deferred vars#3801
make: immediately expand deferred vars#3801maliberty merged 2 commits intoThe-OpenROAD-Project:masterfrom
Conversation
Signed-off-by: Kimplul <kimi.h.kuparinen@gmail.com>
|
I think your methodology is faulty because it's not possible ibex finished in under 1 second. Did you |
|
@rovinski To clarify, I'm not running the full Ibex flow, I've previously finished the flow and running |
|
There is something pathologically bad about NIX if doing essentially no work takes 50s. @hzeller have observed this? |
|
This pull request has been automatically marked as stale because it has not had recent activity. It will be closed in 21 days if no further activity occurs. Remove the |
|
Ping to keep issue active. I haven't looked into the cause for the repeated expansions yet, but I can have a go at it. |
|
I think I have an explanation. Variables marked writes out to In the case of OpenROAD, all of |
|
Expanding an envar should be a millisecond operation unless you are executing some command from within the envar. |
|
Running |
Signed-off-by: Kimplul <kimi.h.kuparinen@gmail.com>
|
Ping again, resolved merge conflict that appeared. Is there something I can do to help get this merged? It's a very minor issue in the grand scheme of things, but still annoying. I believe I've shown what the root cause is (exported deferred variables containing |
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request standardizes the definition and exportation of tool executable paths in flow/scripts/variables.mk by using conditional assignment followed by immediate expansion during export. The changes affect variables such as PYTHON_EXE, OPENROAD_EXE, and KLAYOUT_CMD. A review comment identifies an improvement opportunity to simplify the KLAYOUT_CMD logic by removing a redundant ifeq check, as the ?= operator already handles conditional assignment for undefined variables.
| ifeq ($(KLAYOUT_CMD),) | ||
| export KLAYOUT_CMD := $(shell command -v klayout) | ||
| KLAYOUT_CMD ?= $(shell command -v klayout) | ||
| endif |
There was a problem hiding this comment.
The ifeq ($(KLAYOUT_CMD),) check is redundant here because the ?= operator already ensures that the variable is only assigned if it is currently undefined. Removing this extra conditional block simplifies the logic and makes it consistent with how other tool variables (like PYTHON_EXE or OPENROAD_EXE) are handled in this file. Note that this change also means an explicitly defined empty KLAYOUT_CMD will now be respected rather than overwritten, which is consistent with the behavior of the other tool variables.
KLAYOUT_CMD ?= $(shell command -v klayout)
maliberty
left a comment
There was a problem hiding this comment.
It doesn't seem harmful even if I can't really see why it would be necessary.
When
IN_NIX_SHELLis defined,flow/scripts/variables.mkdefines some commonly used variables likeOPENROAD_EXEwithOPENROAD_EXE ?= $(shell ...). The conditional assignment (?=) is a deferred assignment, so every timeOPENROAD_EXEis expanded, the corresponding shell command is run. Apparently some of these variables are expanded often enough that the deferred assignment has a somewhat significant impact on runtime, here's how longmaketakes to run after having synthesized the Ibex example from the docs:Before:
The fix here is to immediately re-expand the newly defined variables so the shell command is only ran once.
After: